{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# Jacobian for homogenous gas reactor\n",
    "***Energy equation***\n",
    "$$\n",
    "\\frac{dT}{dt}= -\\frac{1}{\\rho c_p}\\sum_{k=1}^{N_{spec}}\\dot{\\omega_{k}} W_k h_k = S_T\n",
    "$$\n",
    "***Species equation***\n",
    "$$\n",
    "\\frac{dY_k}{dt}=\\frac{1}{\\rho}\\dot{\\omega_{k}}W_k=S_{Y_k},\\,\\,\\,k=1\\ldots N_{spec}\n",
    "$$\n",
    "\n",
    "\n",
    "## Environment Setup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "TChem_install_directory ='where/tchem/is/installed'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append(TChem_install_directory+'/lib')\n",
    "import pytchem\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import time"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pre-simulation\n",
    "* Set variables; temperature and stoichiometric ratio (fuel/air).\n",
    "* Convert from stoichiometric ratio to mass fraction of CH4, O2, N2 and AR.\n",
    "* Create samples spaning over the variable ranges."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Pressure, Temperature, and mass fractions\n",
    "one_atm = 101325 # [Pa]\n",
    "T = 1200 # K \n",
    "P = one_atm # Pa\n",
    "Yp_fuel = 0.1\n",
    "Yr_o2 = 0.9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "N=1\n",
    "Nvar = 4\n",
    "sample = np.zeros([N,Nvar])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# sample 1\n",
    "sample[0,0] = T\n",
    "sample[0,1] = P\n",
    "sample[0,2] = Yp_fuel\n",
    "sample[0,3] = Yr_o2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TChem Simulation\n",
    "\n",
    "### Initialize TChem Driver Object\n",
    "\n",
    "* Initialization of Kokkos.\n",
    "* Create a TChem driver object. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "pytchem.initialize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "tchem = pytchem.TChemDriver()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Get help from TChem driver object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on TChemDriver in module pytchem object:\n",
      "\n",
      "class TChemDriver(pybind11_builtins.pybind11_object)\n",
      " |  A class to manage data movement between numpy to kokkos views in TChem::Driver object\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      TChemDriver\n",
      " |      pybind11_builtins.pybind11_object\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __init__(...)\n",
      " |      __init__(self: pytchem.TChemDriver) -> None\n",
      " |  \n",
      " |  computeEnthapyMass(...)\n",
      " |      computeEnthapyMass(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Compute enthalpy mass and mixture enthalpy\n",
      " |  \n",
      " |  computeJacobianHomogeneousGasReactor(...)\n",
      " |      computeJacobianHomogeneousGasReactor(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Compute Jacobian matrix for homogeneous gas reactor\n",
      " |  \n",
      " |  computeNetProductionRatePerMass(...)\n",
      " |      computeNetProductionRatePerMass(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Compute net production rate\n",
      " |  \n",
      " |  computeRHS_HomogeneousGasReactor(...)\n",
      " |      computeRHS_HomogeneousGasReactor(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Compute RHS for homogeneous gas reactor\n",
      " |  \n",
      " |  computeReactionRateConstants(...)\n",
      " |      computeReactionRateConstants(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Compute forward/reverse rate constant\n",
      " |  \n",
      " |  computeTimeAdvanceHomogeneousGasReactor(...)\n",
      " |      computeTimeAdvanceHomogeneousGasReactor(self: pytchem.TChemDriver) -> float\n",
      " |      \n",
      " |      Compute Time Advance for a Homogeneous-Gas Reactor\n",
      " |  \n",
      " |  createAllViews(...)\n",
      " |      createAllViews(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Allocate all necessary workspace for this driver\n",
      " |  \n",
      " |  createEnthapyMass(...)\n",
      " |      createEnthapyMass(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Allocate memory for enthalpy mass  (# samples, # species )\n",
      " |  \n",
      " |  createJacobianHomogeneousGasReactor(...)\n",
      " |      createJacobianHomogeneousGasReactor(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Allocate memory for homogeneous-gas-reactor Jacobian  (# samples, # species + 1  # species + 1)\n",
      " |  \n",
      " |  createKineticModel(...)\n",
      " |      createKineticModel(self: pytchem.TChemDriver, chemkin_input: str, thermo_data: str) -> None\n",
      " |      \n",
      " |      Create a kinetic model from CHEMKIN input files\n",
      " |  \n",
      " |  createNetProductionRatePerMass(...)\n",
      " |      createNetProductionRatePerMass(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Allocate memory for net production rate per mass (# samples, # species)\n",
      " |  \n",
      " |  createRHS_HomogeneousGasReactor(...)\n",
      " |      createRHS_HomogeneousGasReactor(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Allocate memory for homogeneous-gas-reactor RHS  (# samples, # species + 1 )\n",
      " |  \n",
      " |  createReactionRateConstants(...)\n",
      " |      createReactionRateConstants(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Allocate memory for forward/reverse rate constants  (# samples, # reactions )\n",
      " |  \n",
      " |  createStateVector(...)\n",
      " |      createStateVector(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Allocate memory for state vector (# samples, state vector length)\n",
      " |  \n",
      " |  freeAllViews(...)\n",
      " |      freeAllViews(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Free all necessary workspace for this driver\n",
      " |  \n",
      " |  getEnthapyMass(...)\n",
      " |      getEnthapyMass(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrive enthalpy mass per species for all samples\n",
      " |  \n",
      " |  getEnthapyMixMass(...)\n",
      " |      getEnthapyMixMass(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve mixture enthalpy for all samples\n",
      " |  \n",
      " |  getForwardReactionRateConstants(...)\n",
      " |      getForwardReactionRateConstants(*args, **kwargs)\n",
      " |      Overloaded function.\n",
      " |      \n",
      " |      1. getForwardReactionRateConstants(self: pytchem.TChemDriver, sample_index: int) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrive forward rate constants for a single sample\n",
      " |      \n",
      " |      2. getForwardReactionRateConstants(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve forward rate constants  for all samples\n",
      " |  \n",
      " |  getJacobianHomogeneousGasReactor(...)\n",
      " |      getJacobianHomogeneousGasReactor(self: pytchem.TChemDriver, sample_index: int) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrive homogeneous-gas-reactor Jacobian for a single sample\n",
      " |  \n",
      " |  getLengthOfStateVector(...)\n",
      " |      getLengthOfStateVector(self: pytchem.TChemDriver) -> int\n",
      " |      \n",
      " |      Get the size of state vector i.e., rho, P, T, Y_{0-Nspec-1}\n",
      " |  \n",
      " |  getNetProductionRatePerMass(...)\n",
      " |      getNetProductionRatePerMass(*args, **kwargs)\n",
      " |      Overloaded function.\n",
      " |      \n",
      " |      1. getNetProductionRatePerMass(self: pytchem.TChemDriver, sample_index: int) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrive net production rate for a single sample\n",
      " |      \n",
      " |      2. getNetProductionRatePerMass(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve net production rate for all samples\n",
      " |  \n",
      " |  getNumberOfReactions(...)\n",
      " |      getNumberOfReactions(self: pytchem.TChemDriver) -> int\n",
      " |      \n",
      " |      Get the number of reactions registered in the kinetic model\n",
      " |  \n",
      " |  getNumberOfSamples(...)\n",
      " |      getNumberOfSamples(self: pytchem.TChemDriver) -> int\n",
      " |      \n",
      " |      Get the number of samples which is currently used in the driver\n",
      " |  \n",
      " |  getNumberOfSpecies(...)\n",
      " |      getNumberOfSpecies(self: pytchem.TChemDriver) -> int\n",
      " |      \n",
      " |      Get the number of species registered in the kinetic model\n",
      " |  \n",
      " |  getRHS_HomogeneousGasReactor(...)\n",
      " |      getRHS_HomogeneousGasReactor(*args, **kwargs)\n",
      " |      Overloaded function.\n",
      " |      \n",
      " |      1. getRHS_HomogeneousGasReactor(self: pytchem.TChemDriver, sample_index: int) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrive homogeneous-gas-reactor RHS for a single sample\n",
      " |      \n",
      " |      2. getRHS_HomogeneousGasReactor(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve homogeneous-gas-reactor RHS_ for all samples\n",
      " |  \n",
      " |  getReverseReactionRateConstants(...)\n",
      " |      getReverseReactionRateConstants(*args, **kwargs)\n",
      " |      Overloaded function.\n",
      " |      \n",
      " |      1. getReverseReactionRateConstants(self: pytchem.TChemDriver, sample_index: int) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrive reverse rate constants for a single sample\n",
      " |      \n",
      " |      2. getReverseReactionRateConstants(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve reverse rate constants  for all samples\n",
      " |  \n",
      " |  getSpeciesIndex(...)\n",
      " |      getSpeciesIndex(self: pytchem.TChemDriver, species_name: str) -> int\n",
      " |      \n",
      " |      Get species index\n",
      " |  \n",
      " |  getStateVariableIndex(...)\n",
      " |      getStateVariableIndex(self: pytchem.TChemDriver, var_name: str) -> int\n",
      " |      \n",
      " |      Get state variable index\n",
      " |  \n",
      " |  getStateVector(...)\n",
      " |      getStateVector(*args, **kwargs)\n",
      " |      Overloaded function.\n",
      " |      \n",
      " |      1. getStateVector(self: pytchem.TChemDriver, sample_index: int) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve state vector for a single sample\n",
      " |      \n",
      " |      2. getStateVector(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve state vector for all samples\n",
      " |  \n",
      " |  getTimeStep(...)\n",
      " |      getTimeStep(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve time line of all samples\n",
      " |  \n",
      " |  getTimeStepSize(...)\n",
      " |      getTimeStepSize(self: pytchem.TChemDriver) -> numpy.ndarray[numpy.float64]\n",
      " |      \n",
      " |      Retrieve time step sizes of all samples\n",
      " |  \n",
      " |  setNumberOfSamples(...)\n",
      " |      setNumberOfSamples(self: pytchem.TChemDriver, number_of_samples: int) -> None\n",
      " |      \n",
      " |      Set the number of samples; this is used for Kokkos view allocation\n",
      " |  \n",
      " |  setStateVector(...)\n",
      " |      setStateVector(*args, **kwargs)\n",
      " |      Overloaded function.\n",
      " |      \n",
      " |      1. setStateVector(self: pytchem.TChemDriver, sample_index: int, 1d_state_vector: numpy.ndarray[numpy.float64]) -> None\n",
      " |      \n",
      " |      Overwrite state vector for a single sample\n",
      " |      \n",
      " |      2. setStateVector(self: pytchem.TChemDriver, 2d_state_vector: numpy.ndarray[numpy.float64]) -> None\n",
      " |      \n",
      " |      Overwrite state vector for all samples\n",
      " |  \n",
      " |  setTimeAdvanceHomogeneousGasReactor(...)\n",
      " |      setTimeAdvanceHomogeneousGasReactor(self: pytchem.TChemDriver, tbeg: float, tend: float, dtmin: float, dtmax: float, max_num_newton_iterations: float, num_time_iterations_per_interval: float, atol_newton: float, rtol_newton: float, atol_time: float, rtol_time: float) -> None\n",
      " |      \n",
      " |      Set time advance object for homogeneous gas reactor\n",
      " |  \n",
      " |  showViewStatus(...)\n",
      " |      showViewStatus(self: pytchem.TChemDriver) -> None\n",
      " |      \n",
      " |      Print member variable view status\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods inherited from pybind11_builtins.pybind11_object:\n",
      " |  \n",
      " |  __new__(*args, **kwargs) from pybind11_builtins.pybind11_type\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(tchem)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Create Kinetic Model \n",
    "\n",
    "* Inputs are the reactions mechanism files; in this case, we use the GRI3.0 gas reaction mechanism"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "inputs_directory = TChem_install_directory + '/example/data/H2/'\n",
    "tchem.createKineticModel(inputs_directory+'chem.inp',inputs_directory+'therm.dat')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set State Vector\n",
    "\n",
    "* Get index for variables. \n",
    "* Pass a numpy array to the TChem object to set the state vector. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "Variables = ['T','P','H2','O2']\n",
    "indx=[]\n",
    "for var in Variables:\n",
    "    indx += [tchem.getStateVariableIndex(var)]\n",
    "\n",
    "state = np.zeros([N, tchem.getLengthOfStateVector()])\n",
    "for sp in range(N):\n",
    "    state[sp,indx] = sample[sp,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "tchem.setNumberOfSamples(N)\n",
    "tchem.createStateVector()\n",
    "tchem.setStateVector(state)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "tchem.computeJacobianHomogeneousGasReactor()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Jacobian of Homogeneous Gas Reactor's RHS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# get jacobian for sample 1\n",
    "jacobian1 = tchem.getJacobianHomogeneousGasReactor(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[-2.58345151e+00  3.25805619e+02 -3.62006243e+01 -7.56177571e+08\n",
      "   2.17834158e+10  2.22143362e+02 -2.73200920e+09 -2.54627165e+06\n",
      "  -3.09404524e+07]\n",
      " [-5.79033697e-05 -1.07507891e-02 -2.10674121e-03 -4.94015786e+05\n",
      "  -1.75716792e+06  2.12172226e-03  3.79213460e-02 -1.60025933e+02\n",
      "   1.12373574e-03]\n",
      " [-9.19093759e-04 -1.70646045e-01 -3.34400793e-02  3.79213433e-02\n",
      "  -7.62422727e-03  3.34842136e-02 -2.87152595e+07  6.63026992e+01\n",
      "  -7.36375328e+00]\n",
      " [ 8.12846431e-13  3.52077758e-11  1.81936607e-11 -3.92072989e+06\n",
      "   2.16490779e-02  7.28986233e-11  1.13232802e+07 -3.79251009e-12\n",
      "  -3.68012539e-12]\n",
      " [ 0.00000000e+00  0.00000000e+00  0.00000000e+00  4.16773778e+06\n",
      "  -1.48242532e+07  1.02942976e-04  1.20366523e+07  0.00000000e+00\n",
      "   1.23521650e+04]\n",
      " [ 0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00\n",
      "   1.57028372e+07 -1.09044062e-04  0.00000000e+00  0.00000000e+00\n",
      "   0.00000000e+00]\n",
      " [ 2.89516923e-05  5.37539709e-03  1.05337056e-03  2.47007893e+05\n",
      "   8.78583960e+05 -1.06086029e-03 -9.04537712e+05  8.21009388e+01\n",
      "  -5.61867912e-04]\n",
      " [ 9.48045436e-04  1.76021437e-01  3.44934499e-02 -3.91158749e-02\n",
      "   7.86439229e-03 -3.45389745e-02  6.25986470e+06 -2.68849770e+03\n",
      "   1.52098254e+01]\n",
      " [ 0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00\n",
      "   0.00000000e+00  0.00000000e+00  0.00000000e+00  2.70011999e+03\n",
      "  -1.23600117e+04]]\n"
     ]
    }
   ],
   "source": [
    "print(jacobian1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "tchem.computeRHS_HomogeneousGasReactor()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-1.33285683e+02, -2.97114600e-03, -4.71606759e-02,  1.98950722e-11,\n",
       "        0.00000000e+00,  0.00000000e+00,  1.48557322e-03,  4.86462486e-02,\n",
       "        0.00000000e+00])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tchem.getRHS_HomogeneousGasReactor(0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Compute Forward and reverse rate constants per reaction "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "tchem.computeReactionRateConstants()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The forward rate constant has typically an Arrhenius expression,\n",
    "$$\n",
    "{k_f}_i=A_iT^{\\beta_i}\\exp\\left(-\\frac{E_i}{RT}\\right),\n",
    "$$\n",
    "where $A_i$, $\\beta_i$, and $E_i$ are the pre-exponential factor, temperature exponent, and activation energy, respectively, for reaction $i$. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "kfor = tchem.getForwardReactionRateConstants()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Forward rate constants in units of mol, cm3, s :\n",
      " [[1.94132955e+11 6.04973630e+11 2.28740121e+12 3.16043955e+12\n",
      "  2.16916720e-04 1.77968220e+14 3.92833333e+15 1.55555556e+16\n",
      "  2.61726559e+15 2.71391201e+13 1.17142081e+14 2.14055791e+13\n",
      "  1.20833333e+13 1.68600450e+12 6.21438578e+08 2.21914434e+12\n",
      "  1.71864016e+12 2.60222849e+12 3.84295223e+12]]\n"
     ]
    }
   ],
   "source": [
    "print('Forward rate constants in units of mol, cm3, s :\\n',kfor)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For reactions with reverse Arrhenius parameters specified, the reverse rate constant ${k_r}_i$ is computed similar to ${k_f}_i$. If the reverse Arrhenius parameters are not specified, ${k_r}_i$ is computed as\n",
    "$$\n",
    "{k_r}_i={k_f}_i/{K_c}_i,\n",
    "$$\n",
    "where ${K_c}_i$ is the equilibrium constant (in concentration units) for reaction $i$\n",
    "$$\n",
    "{K_c}_i=\\left(\\frac{P_{atm}}{RT}\\right)^{\\sum_{k=1}^{N_{spec}}\\nu_{ki}}{K_p}_i,\\,\\,\\,\n",
    "{K_p}_i=\\exp\\left(\\sum_{k=1}^{N_{spec}}\\nu_{ki}\\left(\\frac{S_k}{R}-\\frac{H_k}{RT}\\right)\\right).\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "krev = tchem.getReverseReactionRateConstants()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Reverse rate constants in units of mol, cm3, s :\n",
      " [[1.19453660e+13 5.94091851e+11 1.88549537e+10 2.65285468e+10\n",
      "  5.53980281e+14 1.11213660e-06 1.51051209e-03 5.02073585e-05\n",
      "  3.43981629e+06 8.08550280e+03 2.10882991e+06 6.26261050e+03\n",
      "  2.96743455e+01 2.13533735e+06 6.72096456e+15 7.74641558e-02\n",
      "  4.04285772e+08 6.01126786e+08 7.45163564e+06]]\n"
     ]
    }
   ],
   "source": [
    "print('Reverse rate constants in units of mol, cm3, s :\\n',krev)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finalize Kokkos. This deletes the TChem object and the data stored as Kokkos views"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "pytchem.finalize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
